package com.example.teesystem.mapper;

import com.example.teesystem.entity.AdvancedTrainingProgress;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.teesystem.entity.Issue;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 28131
* @description 针对表【t_advanced_training_progress】的数据库操作Mapper
* @createDate 2022-04-02 11:05:55
* @Entity com.example.teesystem.entity.AdvancedTrainingProgress
*/
public interface AdvancedTrainingProgressMapper extends BaseMapper<AdvancedTrainingProgress> {
    @Select("select * from t_advanced_training_progress where advanced_training_id = #{id} and student_id = #{studentId}")
    AdvancedTrainingProgress getAdvancedTraining(int id, int studentId);

    @Select({
            "<script>"+
                    "select * from t_advanced_training_progress where student_id = #{studentId} and advanced_training_id in " +
                    "<foreach item = 'item' index = 'index' collection = 'ids' open='(' separator=',' close=')'>" +
                    "#{item}" +
                    "</foreach>"+
                    "</script>"
    })
    List<AdvancedTrainingProgress> getAdvancedTrainingProgressesByIds(@Param("ids") List<Integer> ids,int studentId);

    @Select("select count(*) from t_advanced_training_progress where student_id = #{studentId} and course_id = #{courseId}")
    Integer getAnswerNum(int courseId,int studentId);
}
